-
Notifications
You must be signed in to change notification settings - Fork 13.8k
libcore/net: IpAddr::as_octets()
#136609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libcore/net: IpAddr::as_octets()
#136609
Conversation
If you wish to add a new API, please open an ACP to get approval for it first: https://std-dev-guide.rust-lang.org/development/feature-lifecycle.html#suitability-for-the-standard-library |
Looking at this myself, why (But questions like that are what the ACP review is for.) |
Hmm, yeah, I guess I actually only want to erase length information for the sake of providing I hoped this was a minimal enough change that an ACP wasn't required, but I'm happy to open one. (Maybe this weekend.) |
Generally I ask for an ACP in the vast majority of the cases, since for new stuff I don't know what libs-api might think. Maybe they'd just say to add The common exceptions to having an ACP are things like
But here there might also be some reason that the |
Got it, yep — happy to open one. I appreciate the explanation / reasoning. |
Looks like the methods were accepted rust-lang/libs-team#535 (comment) as |
IpAddr::as_slice()
IpAddr::as_octets()
Updated with ACP's requested changes — if I understand the process correctly, this wants a tracking issue also? @rustbot review |
Adds `const` `Ip*Addr::as_octets` methods providing reference access to `Ip*Addr` octets contents. See rust-lang/libs-team#535 for accepted ACP with a more detailed justification.
Done! @rustbot review |
Thanks! |
ACP
Tracking issue
Adds
const
core::net::IpAddr{,v4,v6}::as_octets()
methods to provide reference access to IP address contents.The concrete usecase for me is allowing the
IpAddr
to provide an extended lifetime in contexts that want a&[u8]
:(Notably, in this case we can't parameterize
AddrSlice
by aconst N: usize
(such thatfn addr_slice(&self) -> [u8; N]
) and maintain object-safety.)